package com.rionosoft.demo.common;

import java.util.ArrayList;
import java.util.List;

import com.rionosoft.demo.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;

public class BaseListViewActivity extends Activity implements OnItemClickListener {
	
	private List<CommonMenuItem> mListData = buildItems(); 
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.common_listview);
        ListView listView = (ListView) findViewById(R.id.common_list);
        CommonListAdapter adapter = new CommonListAdapter(this, mListData);
        listView.setAdapter(adapter);
        listView.setOnItemClickListener(this);
    }
	
	public List<CommonMenuItem> buildItems() {
    	return new ArrayList<CommonMenuItem>();
    }

	@Override
	public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
		CommonMenuItem item = mListData.get(position);
		Class<? extends Activity> clazz = item.getClazz();
		startActivity(new Intent(this, clazz));
	}

}
